package com.ruoyi.im.service.impl;


import com.ruoyi.im.entity.IMUserArea;
import com.ruoyi.im.mapper.IMUserAreaMapper;
import com.ruoyi.im.service.IMUserAreaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * 用户区域接口实现
 */
@Service
public class IMUserAreaServiceImpl implements IMUserAreaService {

    /**
     * 日志
     */
    private Logger logger = LoggerFactory.getLogger(IMUserAreaServiceImpl.class);

    @Resource
    private IMUserAreaMapper IMUserAreaMapper;

    @Override
    public IMUserArea getById(Integer id) {
        return IMUserAreaMapper.selectById(id);
    }

    @Override
    public IMUserArea getUserArea(IMUserArea IMUserArea) {
        return null;
    }

    @Override
    public int addUserArea(IMUserArea IMUserArea) {
        IMUserArea.setCityLevelCode(1);
        IMUserArea.setCountyLevelCode(2);
        IMUserArea.setTownLevelCode(3);
        IMUserArea.setVillageLevelCode(4);
        IMUserArea.setStatus(0);
        IMUserArea.setAreaType(1);
        IMUserArea.setCreateTime(LocalDateTime.now());
        return IMUserAreaMapper.insertUserArea(IMUserArea);
    }

    @Override
    public int modifyUserArea(IMUserArea IMUserArea) {
        IMUserArea.setStatus(0);
        //int timeNow = (int) (System.currentTimeMillis()/1000);
        IMUserArea.setUpdateTime(LocalDateTime.now());
        return IMUserAreaMapper.updateById(IMUserArea);
    }
}
